package pc2brick;

import lejos.nxt.Motor;

public class Radar extends Thread {
	private boolean running;
	
	public Radar ()
	{
		this.running = true;
	}
	
	public void run()
	{
		int speed;
		int sens = 1;
		int lower = 100;
		int higher = 500;
		
		while (this.running)
		{
			speed = (int)(Math.random() * (higher-lower)) + lower;
			
			Motor.B.setSpeed(speed);
			if (sens == 1)
			{
				Motor.B.forward();
				sens = 0;
			}else{
				Motor.B.backward();
				sens = 1;
			}
			
			try {
				Thread.sleep(2000);
			} catch (Exception e) {
			}
		}
	}
	
	public void kill()
	{
		this.running = false;
	}

}
